[WHYjun] WEEK 01 solutions #1978
Merged
WHYjun merged 5 commits intoDaleStudy:mainfrom Nov 13, 2025
Merged
Conversation
haxr369
reviewed
Nov 10, 2025
| return len(numsSet) | ||
|
|
||
| # Use priority queue to sort in O(n) | ||
| sorted = [] |
Contributor
There was a problem hiding this comment.
sorted는 파이썬 내장 정렬 함수라, 같은 이름의 변수를 정의하면 함수 참조가 가려집니다.
이후에 sorted 호출 시 혼동을 일으킬 수 있으니, pq 같은 변수명을 사용하는게 좋을 것 같습니다.
Contributor
Author
There was a problem hiding this comment.
그렇네요. 인터뷰용으로만 쓰다 보니 이런 부분을 놓치네요. 감사합니다.
| for num in numsSet: | ||
| heapq.heappush(sorted, num) | ||
|
|
||
| prev = heapq.heappop(sorted) |
Contributor
There was a problem hiding this comment.
힙큐를 이용해 단순 정렬을 원하시면 heapify로 힙을 구성한 뒤, sorted()로 정렬하는 편이 더 효율적이고, 단순 sorted(numSet)을 호출하셔도 동일한 결과를 얻으실 수 있으십니다.
Contributor
Author
There was a problem hiding this comment.
감사합니다. 일단 heapify로 해두었습니다. 기록용으로 heapq 풀이법 먼저 생각해두었던 것을 남겨둔 거라서요.
Contributor
|
네~! 고생하셨습니다! |
haxr369
approved these changes
Nov 12, 2025
Contributor
haxr369
left a comment
There was a problem hiding this comment.
네! 고생하셨어요!
남은 한주 파이팅입니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!